package com.itcast.service.impl;

import com.itcast.mapper.EmpMapper;
import com.itcast.pojo.JobOption;
import com.itcast.service.ReportServerice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ReportServiceImpl implements ReportServerice {
    @Autowired
    private EmpMapper empMapper;

    /*
     * 统计员工工作职位人数
     * */
    @Override
    public JobOption getJobEmpData() {
        //调取mapper接口
        List<Map<String, Object>> mapList = empMapper.countByEmpJobOption();//map：pos:num
        //封装数据
        List<Object> jobList =mapList.stream().map(map -> map.get("pos")).toList();
        List<Object> dataList =mapList.stream().map(map -> map.get("num")).toList();
        JobOption jobOption = new JobOption();
        jobOption.setJobList(jobList);
        jobOption.setDataList(dataList);
        return jobOption;
    }
    /*
     * 统计员工性别人数
     * */
    @Override
    public List<Map<String, Integer>> getGenderEmpData() {
        //调取mapper接口

        return empMapper.countByEmpGenderOption();
    }
}
